
Component({
  properties: {
    show: {
      type: Boolean,
      value: false
    },
    folder: {
      type: Object,
      value: {}
    }
  },
  data: {
    form: {
      collectionName: '',
      collectionIntro: ''
    }
  },
  methods: {
    beforeOpen () {
      if (this.data.folder && this.data.folder.id) {
        this.data.form.collectionName = this.data.folder.collectionName
        this.data.form.collectionIntro = this.data.folder.intro
        this.data.form.id = this.data.folder.id
      } else {
        this.data.form = {
          collectionName: '',
          collectionIntro: ''
        }
      }
      this.setData({ form : this.data.form })
    },
    close () {
      this.triggerEvent('close')
    },
    confirm () {
      this.triggerEvent('confirm', this.data.form)
    },
    changeInput ({ currentTarget: { dataset: { key } }, detail: { value } }) {
      this.setData({
        ['form.' + key]: value
      })
    }
  },
})